package com.tangtang.core.validator;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * Created by Administrator on 2014/4/10.
 */
public class MustInValidator implements ConstraintValidator<MustIn, Object> {

    MustIn must;

    @Override
    public void initialize(MustIn constraintAnnotation) {
        this.must = constraintAnnotation;
    }

    @Override
    public boolean isValid(Object o, ConstraintValidatorContext constraintValidatorContext) {
        for (Object obj : must.value()) {
            if (obj.equals(o)) {
                return true;
            }
        }
        return false;
    }

}
